<template>
  <view class="box_content">
    <!-- 123123 -->
    <view v-if="list.length > 0">
      <view
        class="content"
        :class="item.is_tong_r == 0 || item.is_tong == 0 ? 'content1' : ''"
        v-for="(item, index) in listv"
        :key="index"
      >
        <view class="date" v-show="!item.is_tong && showYear">
          <view class="line"></view>
          <view class="font" :class="whiteColor ? 'font1' : ''">
            {{ item.date_ym }}</view
          >
          <view class="lines"></view>
        </view>
        <view class="main">
          <view class="main_left">
            <view
              class="hao"
              :class="whiteColor ? 'hao1' : ''"
              v-if="!item.is_tong_r"
              >{{ item.date }}</view
            >
            <view class="shuline">
              <!-- 球 -->
              <view class="qiu" v-if="!item.is_tong_r"></view>
              <!-- 线 -->
              <view class="xian" v-if="!item.is_tong_r"></view>
              <view class="xians" v-else></view>
            </view>
          </view>
          <view class="main_right" @click.stop="goPage(item)">
            <view
              class="right_content"
              :class="whiteColor ? 'right_content1' : ''"
            >
              <view class="right_top">
                <view class="avatar" v-if="item.user">
                  <!-- <u-avatar
                class="zanImg"
                src="https://cdn.uviewui.com/uview/album/1.jpg"
              ></u-avatar> -->
                  <image
                    class="zanImg"
                    :src="item.user.avatar_url"
                    @click.stop="goHome(item.user.user_id)"
                  ></image>
                  <view class="name" :class="whiteColor ? 'name1' : ''">{{
                    item.user.nick_name
                  }}</view>
                </view>

                <view
                  v-show="!flag"
                  class="item_left_clickView"
                  @click.stop="changeClickItem(item)"
                >
                  <image
                    v-if="!item.clickable"
                    class="item_left_click"
                    src="../../static/images/my/icon_grzy_quanxuan.png"
                    mode=""
                  ></image>
                  <image
                    v-else
                    class="item_left_clickable"
                    src="../../static/images/my/icon_grzy_xc_xuanzhong.png"
                    mode=""
                  ></image>
                </view>
              </view>

              <view class="all_detail" >
                <view>
                  <view
                  class="font_title"
                  :class="whiteColor ? 'font_title1' : ''"
                  >{{ item.title }}</view
                >
                <view class="font_box">
                  <view
                    class="font_content"
                    :class="whiteColor ? 'font_content1' : ''"
                    v-html="item.content || item.msg"
                  >
                    <!-- {{ item.content || item.msg }} -->
                  </view>
                  <image
                    v-if="false"
                    class="font_img"
                    src="https://cdn.uviewui.com/uview/album/1.jpg"
                  ></image>
                </view>
                </view>
                

                <view class="zanPing" v-if="isInp">
                  <view class="zanBtn" @click.stop="dianZan(item)">
                    <image
                      class="zanImg"
                      src="@/static/images/icon_sslgt_dianzan.png"
                    ></image>
                    <view class="zanFont" style="margin-right: 43rpx">{{
                      item.like_count
                    }}</view>
                  </view>
                  <view class="zanBtn" @click="pinglun()">
                    <image
                      class="zanImg"
                      src="@/static/images/icon_sslgt_xiaoxi.png"
                    ></image>
                    <view class="zanFont">1234</view>
                  </view>
                  <view class="time" v-if="isDate">
                    {{ item.comment_count }}
                  </view>
                </view>

                <view
                  class="card_content_box_preview"
                  v-if="my_level_id < item.grade_auth"
                  @click.stop="goMember"
                >
                  该内容仅支持{{
                    item.grade_auth == 1
                      ? "元气驿站"
                      : item.grade_auth == 2
                      ? "启初梦谷"
                      : item.grade_auth == 3
                      ? "青空天台"
                      : item.grade_auth == 4
                      ? "无极云顶"
                      : item.grade_auth == 5
                      ? "返朴归源"
                      : ""
                  }}及以上行者查看
                </view>
              </view>

              <!-- 预览样式 -->
              <!-- <view class="Preview_style" v-else @click.stop="goMember">
                该内容仅支持{{
                  item.grade_auth == 1
                    ? "元气驿站"
                    : item.grade_auth == 2
                    ? "启初梦谷"
                    : item.grade_auth == 3
                    ? "青空天台"
                    : item.grade_auth == 4
                    ? "无极云顶"
                    : item.grade_auth == 5
                    ? "返朴归源"
                    : ""
                }}及以上行者查看
              </view> -->
            </view>
          </view>
        </view>
      </view>

      <u-modal
        :show="show"
        :title="'提示'"
        :content="'您还不是行者身份，无法参与共创若想要参与共创需要开通行者身份！'"
        :showCancelButton="true"
        confirmText="去开通"
        cancelText="取消"
        confirmColor="#55B877"
        @confirm="submit"
        @cancel="show = false"
      ></u-modal>

      <view class="bottom" v-if="!flag">
        <view class="bottom_left">
          <view @click="changeClick">
            <image
              v-if="!clickableAll"
              class="item_left_click"
              src="../../static/images/my/icon_grzy_quanxuan.png"
              mode=""
            ></image>
            <image
              v-else
              class="item_left_click"
              src="../../static/images/my/icon_grzy_xc_xuanzhong.png"
              mode=""
            ></image>
          </view>
          <view class="bottom_left_text">全选</view>
        </view>
        <view class="bottom_right" @click="deleteFn">删除</view>
      </view>

      <u-modal
        :show="show1"
        :title="title"
        :content="content"
        confirmColor="#55B877"
        :closeOnClickOverlay="true"
        @confirm="confirm"
        @close="close"
        @cancel="cancel"
        :showCancelButton="true"
      ></u-modal>
    </view>
    
  </view>
</template>
<script>
export default {
  props: {
    isDate: {
      type: Boolean,
      default: false,
    },
    isInp: {
      type: Boolean,
      default: false,
    },
    whiteColor: {
      type: Boolean,
      default: false,
    },
    flag: {
      type: Boolean,
      default: true,
    },
    list: {
      type: Array,
      default: () => [],
    },
    showYear: {
      type: Boolean,
      default: true,
    },
    from: {
      type: String,
      default: "",
    },
    my_level_id: {
      type: Number,
      default: 0,
    },
  },
  watch: {
    list: {
      deep: true, // 深度监听每一个属性值, 如果是对象可以深度监听
      immediate: true, // 进入页面后立即自动调用handler函数
      handler(newValue) {
        this.listv = newValue;
        if (this.listv) {
          for (let i = 0; i < this.listv.length; i++) {
            this.listv[i].clickable = false;
          }
        }

        // console.log(this.listv, "newList");
      },
    },
  },
  data() {
    return {
      show: false,
      show1: false,
      value: "",

      title: "确认删除",
      clickableAll: false,
      content: "确认删除选中内容？",
      listv: [],
      type: "",
    };
  },
  methods: {
    dianZan() {
      uni.$u.toast("点赞啦！！！");
    },
    pinglun() {
      uni.$u.toast("评论啦！！！");
    },
    confirm1() {
      if (!this.isDate) {
        this.show = true;
      }
    },
    change() {},
    submit() {
      uni.navigateTo({
        url: "/pages/member/index",
      });
    },
    changeClickItem(item) {
      this.$forceUpdate();
      item.clickable = !item.clickable;
      // 判断是否全选
      let all = true;
      for (let i = 0; i < this.listv.length; i++) {
        if (this.listv[i].clickable == false) {
          all = false;
        }
      }
      if (all) {
        this.clickableAll = true;
      } else {
        this.clickableAll = false;
      }
    },
    changeClick() {
      this.clickableAll = !this.clickableAll;
      if (this.clickableAll) {
        for (let i = 0; i < this.listv.length; i++) {
          this.listv[i].clickable = true;
        }
      } else {
        for (let i = 0; i < this.listv.length; i++) {
          this.listv[i].clickable = false;
        }
      }
    },
    confirm() {
      let arr = [];
      let num = 0;
      for (let i = 0; i < this.listv.length; i++) {
        if (this.listv[i].clickable == true) {
          arr.push(this.listv[i].history_id);
          num++;
        }
      }
      // console.log(arr, "数组");
      this.deletFn(arr);
    },
    close() {
      this.show1 = false;
    },
    cancel() {
      this.show1 = false;
    },
    // 删除按钮
    deleteFn() {
      let isTrue = true;
      for (let i = 0; i < this.listv.length; i++) {
        // console.log(this.listv[i].clickable);
        if (this.listv[i].clickable == true) {
          isTrue = false;
        }
      }
      if (isTrue == true) {
        uni.$u.toast("您还未选择内容");
      } else {
        this.show1 = true;
      }
    },
    // 删除接口
    deletFn(arr) {
      this.$http
        .historyDel_his_gongchuang({ ids: arr })
        .then((res) => {
          uni.$u.toast(res.message);
          this.show1 = false;
          setTimeout(() => {
            this.$emit("updateDataGongLing");
          }, 1000);
        })
        .catch((error) => {
          uni.$u.toast(error);
        });
    },
    // 跳会员页面
    goMember() {
      uni.navigateTo({
        url: `/pages/member/index`,
      });
    },
    // 进个人主页
    goHome(user_id) {
      uni.navigateTo({
        url: `/pages/home/home?user_id=${user_id}`,
      });
    },
    // 进详情页
    goPage(item) {
      // 导航仪下面的游记 跳微创下面的详情
      if (this.from == "daohangyi") {
        uni.navigateTo({
          url: `/pages/detail/flyDetail?detailType=youji&currentId=${item.id}&from=daohangyi`,
        });
        return;
      }
      uni.navigateTo({
        url: `/pages/detail/coCreateFly?id=${item.id}`,
      });
    },
  },
};
</script>
<style scoped lang="scss">
.box_content {
  height: 100%;
  padding: 40rpx 0 0 0;
  box-sizing: border-box;
}
.content {
  .date {
    // padding-bottom: 40rpx;
    display: flex;
	flex-direction: row;
    justify-content: center;
    align-items: center;
    margin-bottom: 40rpx;
    margin-top: 40rpx;
    .line {
      width: 120rpx;
      height: 2rpx;
      background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, #ccc 100%);
      border-radius: 1rpx 1rpx 1rpx 1rpx;
    }

    .lines {
      width: 120rpx;
      height: 2rpx;
      background: linear-gradient(
        90deg,
        #cccccc 0%,
        rgba(255, 255, 255, 0) 100%
      );
      border-radius: 1rpx 1rpx 1rpx 1rpx;
    }

    .font {
      text-align: center;
      width: 183rpx;
      height: 44rpx;
      font-size: 30rpx;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 400;
      color: #444444;
    }
    .font1 {
      color: #eeeeee;
    }
  }

  .main {
    height: 100%;
    display: flex;
	flex-direction: row;
    // margin: 30rpx 0;

    .main_left {
      // height: 100%;
      width: 110rpx;
      // margin-top: 24rpx;
      display: flex;
      flex-direction: column;

      .hao {
        font-size: 46rpx;
        font-weight: 400;
        color: #444444;
        line-height: 68rpx;
        text-align: center;
      }
      .hao1 {
        color: #eee;
      }

      .shuline {
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;

        .qiu {
          width: 18rpx;
          height: 18rpx;
          background: #d8d8d8;
          border-radius: 9rpx;
          margin-top: 16rpx;
        }

        .xian {
          width: 1rpx;
          // height: 176rpx;
          height: 100%;
          background: #eeeeee;
        }

        .xians {
          width: 1rpx;
          // height: 400rpx;
          height: 100%;
          //   height: 300rpx;
          background: #eeeeee;
        }
      }
    }

    .main_right {
      display: flex;
      align-items: flex-end;
      padding-top: 24rpx;
      box-sizing: border-box;
      .right_content {
        margin-top: 24rpx;
        width: 610rpx;
        // height: 276rpx;
        background-color: #f7f8fa;
        border-radius: 16rpx 16rpx 16rpx 16rpx;
        padding-bottom: 32rpx;

        .right_top {
          display: flex;
          align-items: center;
          justify-content: space-between;
          .avatar {
            display: flex;
            align-items: center;
            // width: 72rpx;
            height: 72rpx;
            padding: 32rpx;

            .zanImg {
              border-radius: 36rpx;
              width: 72rpx;
              height: 72rpx;
            }

            .name {
              margin-left: 16rpx;
              font-size: 24rpx;
              font-family: PingFang SC-Medium, PingFang SC;
              font-weight: 400;
              color: #888888;
              line-height: 36rpx;
            }
            .name1 {
              color: #eeeeee;
            }
          }
          .item_left_clickView {
            margin-right: 24rpx;
            .item_left_click {
              width: 40rpx;
              height: 40rpx;
            }
            .item_left_clickable {
              width: 40rpx;
              height: 40rpx;
            }
          }
        }
        .all_detail {
          position: relative;
          .card_content_box_preview {
            color: #eeeeee;
            padding-top: 30rpx;
            box-sizing: border-box;
            position: absolute;
            top: 0;
            background: linear-gradient(
              360deg,
              rgba(48, 53, 77, 1) 50%,
              rgba(49, 57, 79, 0) 100%
            );
            text-align: center;
            width: 100%;
            height: 100%;
          }
        }
        .Preview_style {
          width: 100%;
          // height: 300rpx;
          border-radius: 16rpx;
          // background: rgba(105, 113, 151, 0.7);
          margin-top: 24rpx;
          text-align: center;
          // line-height: 300rpx;
          // color: white;
        }
        .font_title {
          // margin-top: 20rpx;
          margin-left: 32rpx;
          font-size: 30rpx;
          font-weight: 400;
          color: #444444;
        }
        .font_title1 {
          color: #eeeeee;
        }
        .font_box {
          display: flex;
          align-items: center;
          padding: 0 32rpx;
          margin-top: 20rpx;
          .font_content {
            // width: 542rpx;
            width: 100%;
            // height: 88rpx;
            line-height: 44rpx;
            font-size: 30rpx;
            font-weight: 400;
            color: #444444;
            // margin-left: 32rpx;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            flex: 1;
          }
          .font_content1 {
            color: #eee;
          }
          .font_img {
            width: 88rpx;
            height: 88rpx;
            margin-left: 24rpx;
          }
        }

        .zanPing {
          // margin-left: 32rpx;
          display: flex;
          position: relative;
          margin: 20rpx 32rpx;
          .zanBtn {
            display: flex;
            align-items: center;

            .zanImg {
              width: 40rpx;
              height: 40rpx;
            }

            .zanFont {
              margin: 0 10rpx;
              line-height: 40rpx;
              font-size: 24rpx;
              color: #888888;
            }
          }
          .time {
            font-size: 24rpx;
            font-family: PingFang SC-Medium, PingFang SC;
            font-weight: 400;
            color: #888888;
            position: absolute;
            right: 0;
          }
        }
      }
      .right_content1 {
        background: rgba(39, 39, 39, 0.5);
      }
    }
  }
}
.content1 {
  margin-top: 40rpx;
}
.inp {
  width: 546rpx;
  margin-left: 32rpx;
  height: 88rpx;
  background: #eeeeee;
  border-radius: 16rpx 16rpx 16rpx 16rpx;
  display: flex;
  align-items: center;
  padding: 22rpx 32rpx;
  box-sizing: border-box;
  margin-top: 30rpx;
}
.inp1 {
  background: rgba(39, 44, 41, 0.5);
}
.bottom {
  width: 100%;
  height: 112rpx;
  background: #272727;
  position: fixed;
  bottom: 0;
  left: 0;
  padding: 16rpx 30rpx;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .bottom_left {
    display: flex;
    align-items: center;
    .item_left_click {
      width: 40rpx;
      height: 40rpx;
    }
    .bottom_left_text {
      margin-left: 16rpx;
      color: #eeeeee;
      font-size: 30rpx;
    }
  }

  .bottom_right {
    width: 250rpx;
    height: 80rpx;
    background: #ee6060;
    border-radius: 48rpx;
    text-align: center;
    line-height: 80rpx;
    font-size: 30rpx;
    color: #eeeeee;
  }
}

/deep/.u-modal__content__text {
  text-align: center;
}
.empty_view {
  margin-top: 300rpx;
  image {
    margin: 0 auto;
    width: 410rpx;
    height: 410rpx;
  }
  view {
    font-size: 30rpx;
    color: #d8d8d8;
    text-align: center;
  }
}
</style>